/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package my12306.http;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;

/**
 *
 * @author Jack
 */
public class JSONObject {
    //{"json":"hello world"}

    HashMap<String, String> values = new HashMap<String, String>();

    public JSONObject(String rawString) {
        String[] strs = rawString.replace("{", "").replace("}", "").split(",");

        for (String obj : strs) {
            try {
                String[] value = obj.split(":");
                values.put(value[0].replace("\"", ""), value[1].replace("\"", ""));
            } catch (Exception ex) {
            }
        }
    }

    public JSONObject(InputStream in) throws IOException {
        this(new DataInputStream(in).readUTF());
    }

    public String get(String key) {
        return values.get(key);
    }
}
